import React from 'react';
import { Modal, Form } from 'antd';
import FormCondition from '@/components/FormCondition';

const FormDirectory = (props) => {
  const { visible = false, onClose, confirmLoading, handleUpData } = props;
  const { detail = {}, show } = visible
  const { sectionId } = detail
  const [form] = Form.useForm();

  // 确认提交
  const handleUpAudit = () => {
    form.validateFields().then((values) => {
      handleUpData({ id: sectionId, ...values });
    });
  };

  const formItems = [
    {
      label: `节标题`,
      name: 'sectionName',
      maxLength: 30,
    },
  ];

  const modalProps = {
    title: `添加一节`,
    width: 650,
    visible: show,
    maskClosable: true,
    destroyOnClose: true,
    zIndex: 1001,
    confirmLoading: confirmLoading,
  };

  return (
    <Modal {...modalProps} onCancel={onClose} onOk={handleUpAudit}>
      <FormCondition form={form} formItems={formItems} initialValues={detail}></FormCondition>
    </Modal>
  );
};

export default FormDirectory;
